<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
    <channel>
        <title>freepost</title>
        <description></description>
        <link>{{ base_url }}</link>
        <lastBuildDate>{{ now () }}</lastBuildDate>
        
        {% for post in posts %}
            {# freepost URL of this post #}
            {% set freepost_url = base_url ~ url ('post', hash_id=post.hashId) %}
            
            <item>
                <guid isPermaLink="false">{{ post.hashId }}</guid>
                <title>{{ post.title }}</title>
                <description>
                    <![CDATA[
                        <p>{{ post.text }}</p>
                        <p>{{ post.vote }} votes, <a href="{{ freepost_url }}">{{ post.commentsCount ~ ' comments' if post.commentsCount > 0 else 'discuss' }}</a></p>
                    ]]>
                </description>
                <link>{{ post.link if post.link and post.link|length > 0 else freepost_url }}</link>
                <freepostLink>{{ freepost_url }}</freepostLink>
                <pubDate>{{ post.created }}</pubDate>
                <author>{{ post.username }}</author>
            </item>
        {% endfor %}
    </channel>
</rss>
